export function encode64(text: string): string {
  return btoa(String.fromCharCode(...new TextEncoder().encode(text)));
}

export function decode64(text: string): string {
  return new TextDecoder().decode(
    Uint8Array.from(atob(text), (c) => c.charCodeAt(0))
  );
}

export function getBitSizeStr(num: number): string {
    if (num < 1024) {
        return `${num}B`
    }
    if (num < 1024 * 1024) {
        return `${(num / 1024).toFixed(2)}KB`
    }
    if(num < 1024 * 1024 * 1024) {
        return `${(num / 1024 / 1024).toFixed(2)}MB`
    }
    return `${(num / 1024 / 1024 / 1024).toFixed(2)}GB`
}